'use strict';

new Vue({
  el: '#register',
  data: {
    email: '',
    password: '',
    name: '',
    position: '',
  },
  methods: {
    doRegister() {
      const body = {
        email: this.email,
        password: this.password,
        name: this.name,
        position: this.position,
      };
      //   const that = this;
      $.ajax({
        url: '../register',
        type: 'POST',
        data: body,
        success(data) {
          console.log(data);
          alert('注册成功');
          window.location.href = 'login.html';
        },
        error(data) {
          console.log(data);
          alert('注册失败');
        },
      });
    },
  },
});
